import random as r

surnName = ['张', '金', '李', '王', '赵', '钱', '孙',
            '吴', '郑', '冯', '陈', '魏', '沈', '程', '许', '徐', '韩', '杨', '方']
secondName = ['玉', '明', '龙', '芳', '军', '玲', '成',
              '达', '文', '景', '欣', '可', '启', '小', '涵', '兴', '诺', '涛', '仕', '光']
thirdName = ['', '立', '玲', '', '国', '', '明', '宇',
             '辉', '达', '仪', '', '凡', '晨', '', '高', '佳', '浩', '志', '瑞', '锐']
majorCode = range(50)
sexCode = ['1', '0']#male=1, female=0
lessonCode = range(200)


with open("studentInfo.txt", "w") as f:
    #metadeta
    #content: student number
    f.write('###')
    totalStudent = 20000
    f.write(str(totalStudent))
    f.write('###\n')

    #student data
    for i in range(totalStudent):
        grade = str(int(2015+i/5000))
        s_id = grade
        for j in range(6 - len(str(i))):
            s_id += '0'
        s_id += str(i)
        name = r.choice(surnName)+r.choice(secondName)+r.choice(thirdName)
        major = r.choice(majorCode)
        sex = r.choice(sexCode)
        password = '123456'
        lesson = ''
        for j in range(r.randint(5, 10)):
            thisLesson = str(r.choice(lessonCode))
            for k in range(3 - len(thisLesson)):
                lesson += '0'
            lesson += thisLesson
        #data in each line: id, name, sex, major, grade, key, lesson
        f.write(s_id+' '+name+' '+sex+' '+str(major)+' '+grade+' '+password+' '+lesson+'\n')
    f.write('#')
